package com.zzxy.spring.domain;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

import java.util.*;

/**
 * @author aven
 * @description: TODO
 */
public class User implements BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
    private String username;
    private String password;
    private Address address;

    private String sex;

    private String birthday;

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    private Set<String> cars;
    private Map<String,String> infos;

    private Properties properties;

    private String[] memebers;

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", address=" + address +
                ", cars=" + cars +
                ", infos=" + infos +
                ", properties=" + properties +
                ", memebers=" + Arrays.toString(memebers) +
                ", age=" + age +
                '}';
    }

    public String[] getMemebers() {
        return memebers;
    }

    public void setMemebers(String[] memebers) {
        this.memebers = memebers;
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    public Map<String, String> getInfos() {
        return infos;
    }

    public void setInfos(Map<String, String> infos) {
        this.infos = infos;
    }

    public Set<String> getCars() {
        return cars;
    }

    public void setCars(Set<String> cars) {
        this.cars = cars;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    private Integer age;

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public User() {
        System.out.println("1.构造方法");
    }

    public User(String username, String passwrod) {
        this.username = username;
        this.password = passwrod;
    }

    public User(String username, Integer age) {
        this.username = username;
        this.age = age;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        System.out.println("2.设置username 属性");
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("4.setBeanFactory: " + beanFactory);
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3.setBeanName: " + s);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("9.bean销毁");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("6.属性设置完成");
    }

    public void myInit() {
        System.out.println("7.自定义的init...");
    }

    public void myDestoy() {
        System.out.println("10.自定义的destroy...");
    }

}
